Skip to content

Commit 9bba993

Browse files
committed
update
1 parent a847f49 commit 9bba993

95 files changed

Lines changed: 1775 additions & 336 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Samples Java Spring (JDK11)
2+
3+
on:
4+
push:
5+
paths:
6+
# servers
7+
- samples/server/petstore/springboot-implicitHeaders/**
8+
- samples/server/petstore/springboot-implicitHeaders-annotationLibrary/**
9+
pull_request:
10+
paths:
11+
# servers
12+
- samples/server/petstore/springboot-implicitHeaders/**
13+
- samples/server/petstore/springboot-implicitHeaders-annotationLibrary/**
14+
jobs:
15+
build:
16+
name: Build
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
sample:
22+
# servers
23+
- samples/server/petstore/springboot-implicitHeaders
24+
- samples/server/petstore/springboot-implicitHeaders-annotationLibrary
25+
steps:
26+
- uses: actions/checkout@v5
27+
- uses: actions/setup-java@v5
28+
with:
29+
distribution: 'temurin'
30+
java-version: 11
31+
- name: Cache maven dependencies
32+
uses: actions/cache@v5
33+
env:
34+
cache-name: maven-repository
35+
with:
36+
path: |
37+
~/.m2
38+
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
39+
- name: Build
40+
working-directory: ${{ matrix.sample }}
41+
run: mvn clean package --no-transfer-progress

bin/configs/spring-boot-implicitHeaders-annotationLibrary.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ additionalProperties:
88
annotationLibrary: none
99
hideGenerationTimestamp: "true"
1010
implicitHeadersRegex: .*
11+
useSpringBoot3: false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.openapitools.api;
2+
3+
import org.springframework.web.context.request.NativeWebRequest;
4+
5+
import jakarta.servlet.http.HttpServletResponse;
6+
import java.io.IOException;
7+
8+
public class ApiUtil {
9+
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
10+
try {
11+
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
12+
if (res != null) {
13+
res.setCharacterEncoding("UTF-8");
14+
res.addHeader("Content-Type", contentType);
15+
res.getWriter().print(example);
16+
}
17+
} catch (IOException e) {
18+
throw new RuntimeException(e);
19+
}
20+
}
21+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.21.0-SNAPSHOT).
3+
* https://openapi-generator.tech
4+
* Do not edit the class manually.
5+
*/
6+
package org.openapitools.api;
7+
8+
import org.openapitools.model.Bar;
9+
import org.openapitools.model.BarCreate;
10+
import io.swagger.v3.oas.annotations.ExternalDocumentation;
11+
import io.swagger.v3.oas.annotations.Operation;
12+
import io.swagger.v3.oas.annotations.Parameter;
13+
import io.swagger.v3.oas.annotations.Parameters;
14+
import io.swagger.v3.oas.annotations.media.ArraySchema;
15+
import io.swagger.v3.oas.annotations.media.Content;
16+
import io.swagger.v3.oas.annotations.media.Schema;
17+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
18+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
19+
import io.swagger.v3.oas.annotations.tags.Tag;
20+
import io.swagger.v3.oas.annotations.enums.ParameterIn;
21+
import io.swagger.v3.oas.annotations.media.ExampleObject;
22+
import org.springframework.http.HttpStatus;
23+
import org.springframework.http.MediaType;
24+
import org.springframework.http.ResponseEntity;
25+
import org.springframework.validation.annotation.Validated;
26+
import org.springframework.web.bind.annotation.*;
27+
import org.springframework.web.context.request.NativeWebRequest;
28+
import org.springframework.web.multipart.MultipartFile;
29+
30+
import jakarta.validation.Valid;
31+
import jakarta.validation.constraints.*;
32+
import java.util.List;
33+
import java.util.Map;
34+
import java.util.Optional;
35+
import jakarta.annotation.Generated;
36+
37+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.21.0-SNAPSHOT")
38+
@Validated
39+
@Tag(name = "Bar", description = "the Bar API")
40+
public interface BarApi {
41+
42+
default Optional<NativeWebRequest> getRequest() {
43+
return Optional.empty();
44+
}
45+
46+
String PATH_CREATE_BAR = "/bar";
47+
/**
48+
* POST /bar : Create a Bar
49+
*
50+
* @param barCreate (required)
51+
* @return Bar created (status code 200)
52+
*/
53+
@Operation(
54+
operationId = "createBar",
55+
summary = "Create a Bar",
56+
tags = { "Bar" },
57+
responses = {
58+
@ApiResponse(responseCode = "200", description = "Bar created", content = {
59+
@Content(mediaType = "application/json", schema = @Schema(implementation = Bar.class))
60+
})
61+
}
62+
)
63+
@RequestMapping(
64+
method = RequestMethod.POST,
65+
value = BarApi.PATH_CREATE_BAR,
66+
produces = { "application/json" },
67+
consumes = { "application/json" }
68+
)
69+
default ResponseEntity<Bar> createBar(
70+
@Parameter(name = "BarCreate", description = "", required = true) @Valid @RequestBody BarCreate barCreate
71+
) {
72+
getRequest().ifPresent(request -> {
73+
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
74+
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
75+
String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"foo\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"fooPropA\" : \"fooPropA\", \"href\" : \"href\", \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"@schemaLocation\" : \"@schemaLocation\" }, \"href\" : \"href\", \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"@schemaLocation\" : \"@schemaLocation\", \"barPropA\" : \"barPropA\" }";
76+
ApiUtil.setExampleResponse(request, "application/json", exampleString);
77+
break;
78+
}
79+
}
80+
});
81+
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
82+
83+
}
84+
85+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.openapitools.api;
2+
3+
import org.openapitools.model.Bar;
4+
import org.openapitools.model.BarCreate;
5+
6+
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.MediaType;
10+
import org.springframework.http.ResponseEntity;
11+
import org.springframework.stereotype.Controller;
12+
import org.springframework.web.bind.annotation.PathVariable;
13+
import org.springframework.web.bind.annotation.RequestBody;
14+
import org.springframework.web.bind.annotation.RequestHeader;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.CookieValue;
17+
import org.springframework.web.bind.annotation.RequestParam;
18+
import org.springframework.web.bind.annotation.RequestPart;
19+
import org.springframework.web.multipart.MultipartFile;
20+
import org.springframework.web.context.request.NativeWebRequest;
21+
22+
import jakarta.validation.constraints.*;
23+
import jakarta.validation.Valid;
24+
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.Optional;
28+
import jakarta.annotation.Generated;
29+
30+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.21.0-SNAPSHOT")
31+
@Controller
32+
@RequestMapping("${openapi.byRefOrValue.base-path:}")
33+
public class BarApiController implements BarApi {
34+
35+
private final NativeWebRequest request;
36+
37+
@Autowired
38+
public BarApiController(NativeWebRequest request) {
39+
this.request = request;
40+
}
41+
42+
@Override
43+
public Optional<NativeWebRequest> getRequest() {
44+
return Optional.ofNullable(request);
45+
}
46+
47+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.21.0-SNAPSHOT).
3+
* https://openapi-generator.tech
4+
* Do not edit the class manually.
5+
*/
6+
package org.openapitools.api;
7+
8+
import org.openapitools.model.Foo;
9+
import org.openapitools.model.FooRefOrValue;
10+
import org.springframework.lang.Nullable;
11+
import io.swagger.v3.oas.annotations.ExternalDocumentation;
12+
import io.swagger.v3.oas.annotations.Operation;
13+
import io.swagger.v3.oas.annotations.Parameter;
14+
import io.swagger.v3.oas.annotations.Parameters;
15+
import io.swagger.v3.oas.annotations.media.ArraySchema;
16+
import io.swagger.v3.oas.annotations.media.Content;
17+
import io.swagger.v3.oas.annotations.media.Schema;
18+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
19+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
20+
import io.swagger.v3.oas.annotations.tags.Tag;
21+
import io.swagger.v3.oas.annotations.enums.ParameterIn;
22+
import io.swagger.v3.oas.annotations.media.ExampleObject;
23+
import org.springframework.http.HttpStatus;
24+
import org.springframework.http.MediaType;
25+
import org.springframework.http.ResponseEntity;
26+
import org.springframework.validation.annotation.Validated;
27+
import org.springframework.web.bind.annotation.*;
28+
import org.springframework.web.context.request.NativeWebRequest;
29+
import org.springframework.web.multipart.MultipartFile;
30+
31+
import jakarta.validation.Valid;
32+
import jakarta.validation.constraints.*;
33+
import java.util.List;
34+
import java.util.Map;
35+
import java.util.Optional;
36+
import jakarta.annotation.Generated;
37+
38+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.21.0-SNAPSHOT")
39+
@Validated
40+
@Tag(name = "Foo", description = "the Foo API")
41+
public interface FooApi {
42+
43+
default Optional<NativeWebRequest> getRequest() {
44+
return Optional.empty();
45+
}
46+
47+
String PATH_CREATE_FOO = "/foo";
48+
/**
49+
* POST /foo : Create a Foo
50+
*
51+
* @param foo The Foo to be created (optional)
52+
* @return Error (status code 201)
53+
*/
54+
@Operation(
55+
operationId = "createFoo",
56+
summary = "Create a Foo",
57+
tags = { "Foo" },
58+
responses = {
59+
@ApiResponse(responseCode = "201", description = "Error", content = {
60+
@Content(mediaType = "application/json", schema = @Schema(implementation = FooRefOrValue.class))
61+
})
62+
}
63+
)
64+
@RequestMapping(
65+
method = RequestMethod.POST,
66+
value = FooApi.PATH_CREATE_FOO,
67+
produces = { "application/json" },
68+
consumes = { "application/json;charset=utf-8" }
69+
)
70+
default ResponseEntity<FooRefOrValue> createFoo(
71+
@Parameter(name = "Foo", description = "The Foo to be created") @Valid @RequestBody(required = false) @Nullable Foo foo
72+
) {
73+
getRequest().ifPresent(request -> {
74+
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
75+
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
76+
String exampleString = "{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"fooPropA\" : \"fooPropA\", \"href\" : \"href\", \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"@schemaLocation\" : \"@schemaLocation\" }";
77+
ApiUtil.setExampleResponse(request, "application/json", exampleString);
78+
break;
79+
}
80+
}
81+
});
82+
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
83+
84+
}
85+
86+
87+
String PATH_GET_ALL_FOOS = "/foo";
88+
/**
89+
* GET /foo : GET all Foos
90+
*
91+
* @return Success (status code 200)
92+
*/
93+
@Operation(
94+
operationId = "getAllFoos",
95+
summary = "GET all Foos",
96+
tags = { "Foo" },
97+
responses = {
98+
@ApiResponse(responseCode = "200", description = "Success", content = {
99+
@Content(mediaType = "application/json;charset=utf-8", array = @ArraySchema(schema = @Schema(implementation = FooRefOrValue.class)))
100+
})
101+
}
102+
)
103+
@RequestMapping(
104+
method = RequestMethod.GET,
105+
value = FooApi.PATH_GET_ALL_FOOS,
106+
produces = { "application/json;charset=utf-8" }
107+
)
108+
default ResponseEntity<List<FooRefOrValue>> getAllFoos(
109+
110+
) {
111+
getRequest().ifPresent(request -> {
112+
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
113+
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json;charset=utf-8"))) {
114+
String exampleString = "[ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"fooPropA\" : \"fooPropA\", \"href\" : \"href\", \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"fooPropA\" : \"fooPropA\", \"href\" : \"href\", \"id\" : \"id\", \"fooPropB\" : \"fooPropB\", \"@schemaLocation\" : \"@schemaLocation\" } ]";
115+
ApiUtil.setExampleResponse(request, "application/json;charset=utf-8", exampleString);
116+
break;
117+
}
118+
}
119+
});
120+
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
121+
122+
}
123+
124+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.openapitools.api;
2+
3+
import org.openapitools.model.Foo;
4+
import org.openapitools.model.FooRefOrValue;
5+
import org.springframework.lang.Nullable;
6+
7+
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.http.HttpStatus;
10+
import org.springframework.http.MediaType;
11+
import org.springframework.http.ResponseEntity;
12+
import org.springframework.stereotype.Controller;
13+
import org.springframework.web.bind.annotation.PathVariable;
14+
import org.springframework.web.bind.annotation.RequestBody;
15+
import org.springframework.web.bind.annotation.RequestHeader;
16+
import org.springframework.web.bind.annotation.RequestMapping;
17+
import org.springframework.web.bind.annotation.CookieValue;
18+
import org.springframework.web.bind.annotation.RequestParam;
19+
import org.springframework.web.bind.annotation.RequestPart;
20+
import org.springframework.web.multipart.MultipartFile;
21+
import org.springframework.web.context.request.NativeWebRequest;
22+
23+
import jakarta.validation.constraints.*;
24+
import jakarta.validation.Valid;
25+
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.Optional;
29+
import jakarta.annotation.Generated;
30+
31+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.21.0-SNAPSHOT")
32+
@Controller
33+
@RequestMapping("${openapi.byRefOrValue.base-path:}")
34+
public class FooApiController implements FooApi {
35+
36+
private final NativeWebRequest request;
37+
38+
@Autowired
39+
public FooApiController(NativeWebRequest request) {
40+
this.request = request;
41+
}
42+
43+
@Override
44+
public Optional<NativeWebRequest> getRequest() {
45+
return Optional.ofNullable(request);
46+
}
47+
48+
}

samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
import org.springframework.web.bind.annotation.RequestPart;
1818
import org.springframework.web.multipart.MultipartFile;
1919

20-
import javax.validation.constraints.*;
21-
import javax.validation.Valid;
20+
import jakarta.validation.constraints.*;
21+
import jakarta.validation.Valid;
2222

2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.Optional;
26-
import javax.annotation.Generated;
26+
import jakarta.annotation.Generated;
2727

28-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
28+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.21.0-SNAPSHOT")
2929
@Controller
3030
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
3131
public class AnotherFakeApiController implements AnotherFakeApi {

0 commit comments

Comments
 (0)