-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
b040213
committed
Oct 31, 2024
1 parent
ed3b8c1
commit 9dc9d17
Showing
23 changed files
with
1,826 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
.vscode | ||
.env | ||
.env | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/ApiUtil.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/BusinessUnitApi.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/BusinessUnitApiController.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/Error.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/Program.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/ProgramDateTimes.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/ProgramImage.class | ||
/srgssr-api/target/classes/ch/srgssr/epg/api/ProgramPeopleInner.class | ||
/srgssr-api/target/classes/org/openapitools/configuration/HomeController.class | ||
/srgssr-api/target/classes/org/openapitools/configuration/SpringDocConfiguration.class | ||
/srgssr-api/target/classes/org/openapitools/OpenApiGeneratorApplication.class | ||
/srgssr-api/target/classes/org/openapitools/RFC3339DateFormat.class | ||
/srgssr-api/target/classes/application.properties | ||
/srgssr-api/target/classes/openapi.yaml | ||
/srgssr-api/target/classes/swagger_srgssr_epg_v3.0.7.yaml | ||
/srgssr-api/target/maven-archiver/pom.properties | ||
/srgssr-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst | ||
/srgssr-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst | ||
/srgssr-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst | ||
/srgssr-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst | ||
/srgssr-api/target/surefire-reports/org.openapitools.OpenApiGeneratorApplicationTests.txt | ||
/srgssr-api/target/surefire-reports/TEST-org.openapitools.OpenApiGeneratorApplicationTests.xml | ||
/srgssr-api/target/test-classes/org/openapitools/OpenApiGeneratorApplicationTests.class | ||
/srgssr-api/target/openapi-spring-3.0.7.jar | ||
/srgssr-api/target/openapi-spring-3.0.7.jar.original |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
srgssr-api/.openapi-generator/swagger_srgssr_epg_v3.0.7.yaml-default.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f1cae3d507e50f5d1c6192eb9b0d22dcc1c0b784b78dacda819de9c79605f7b8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# OpenAPI generated server | ||
|
||
Spring Boot Server | ||
|
||
## Overview | ||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. | ||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. | ||
|
||
|
||
The underlying library integrating OpenAPI to Spring Boot is [springdoc](https://springdoc.org). | ||
Springdoc will generate an OpenAPI v3 specification based on the generated Controller and Model classes. | ||
The specification is available to download using the following url: | ||
http://localhost:8080/v3/api-docs/ | ||
|
||
Start your server as a simple java application | ||
|
||
You can view the api documentation in swagger-ui by pointing to | ||
http://localhost:8080/swagger-ui.html | ||
|
||
Change default port value in application.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>openapi-spring</artifactId> | ||
<packaging>jar</packaging> | ||
<name>openapi-spring</name> | ||
<version>3.0.7</version> | ||
<properties> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>${java.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.version}</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<springdoc.version>1.6.8</springdoc.version> | ||
<swagger-ui.version>4.10.3</swagger-ui.version> | ||
</properties> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.0</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-commons</artifactId> | ||
</dependency> | ||
<!--SpringDoc dependencies --> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-ui</artifactId> | ||
<version>${springdoc.version}</version> | ||
</dependency> | ||
<!-- @Nullable annotation --> | ||
<dependency> | ||
<groupId>com.google.code.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<version>3.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>jackson-databind-nullable</artifactId> | ||
<version>0.2.2</version> | ||
</dependency> | ||
<!-- Bean Validation API support --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ch.srgssr.epg.api; | ||
|
||
import org.springframework.web.context.request.NativeWebRequest; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
public class ApiUtil { | ||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { | ||
try { | ||
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class); | ||
res.setCharacterEncoding("UTF-8"); | ||
res.addHeader("Content-Type", contentType); | ||
res.getWriter().print(example); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
srgssr-api/src/main/java/ch/srgssr/epg/api/BusinessUnitApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (6.0.1). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
package ch.srgssr.epg.api; | ||
|
||
import org.springframework.format.annotation.DateTimeFormat; | ||
import ch.srgssr.epg.api.Error; | ||
import java.time.LocalDate; | ||
import ch.srgssr.epg.api.Program; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.*; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import javax.annotation.Generated; | ||
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-10-31T10:50:32.787731300+01:00[Europe/Zurich]") | ||
@Validated | ||
@Tag(name = "{businessUnit}") | ||
public interface BusinessUnitApi { | ||
|
||
default Optional<NativeWebRequest> getRequest() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* GET /{businessUnit}/{broadcastType}/stations/{stationName} : EPG Data | ||
* Retrieve EPG data by providing: business unit name, broadcast type, station name and date | ||
* | ||
* @param businessUnit Supported business units are srf, rsi and rts (required) | ||
* @param broadcastType Supported broadcast types are tv and radio (required) | ||
* @param stationName Supported station names are: SRF Radio: srf-1, srf-2,srf-2-kultur, srf-3, srf-4, srf-musikwelle, srf-virus. SRF TV: srf-1, srf-2, srf-info. RTS TV: rts-1, rts-2. RSI Radio: rete-uno, rete-due, rete-tre. RSI TV: la-1, la-2 (required) | ||
* @param authorization Pass the access-key as a Bearer token in Authorization header. In the developer portal, Authorization header is attached on OAuth authentication. (optional) | ||
* @param date Date should be entererd in YYYY-MM-DD format. E.g.: 2020-05-01. If not specified current date will be considered. (optional) | ||
* @return OK (status code 200) | ||
* or Bad Request (status code 400) | ||
* or Unauthorized (status code 401) | ||
* or Not Found (status code 404) | ||
* or Too Many Requests (status code 429) | ||
*/ | ||
@Operation( | ||
operationId = "ePGData", | ||
summary = "EPG Data", | ||
tags = { "EPG Data" }, | ||
responses = { | ||
@ApiResponse(responseCode = "200", description = "OK", content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = Program.class)) | ||
}), | ||
@ApiResponse(responseCode = "400", description = "Bad Request", content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) | ||
}), | ||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) | ||
}), | ||
@ApiResponse(responseCode = "404", description = "Not Found", content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) | ||
}), | ||
@ApiResponse(responseCode = "429", description = "Too Many Requests", content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) | ||
}) | ||
}, | ||
security = { | ||
@SecurityRequirement(name = "srg_auth", scopes={ }) | ||
} | ||
) | ||
@RequestMapping( | ||
method = RequestMethod.GET, | ||
value = "/{businessUnit}/{broadcastType}/stations/{stationName}", | ||
produces = { "application/json" } | ||
) | ||
default ResponseEntity<List<Program>> ePGData( | ||
@Parameter(name = "businessUnit", description = "Supported business units are srf, rsi and rts", required = true) @PathVariable("businessUnit") List<String> businessUnit, | ||
@Parameter(name = "broadcastType", description = "Supported broadcast types are tv and radio", required = true) @PathVariable("broadcastType") List<String> broadcastType, | ||
@Parameter(name = "stationName", description = "Supported station names are: SRF Radio: srf-1, srf-2,srf-2-kultur, srf-3, srf-4, srf-musikwelle, srf-virus. SRF TV: srf-1, srf-2, srf-info. RTS TV: rts-1, rts-2. RSI Radio: rete-uno, rete-due, rete-tre. RSI TV: la-1, la-2", required = true) @PathVariable("stationName") List<String> stationName, | ||
@Parameter(name = "Authorization", description = "Pass the access-key as a Bearer token in Authorization header. In the developer portal, Authorization header is attached on OAuth authentication.") @RequestHeader(value = "Authorization", required = false) String authorization, | ||
@Parameter(name = "date", description = "Date should be entererd in YYYY-MM-DD format. E.g.: 2020-05-01. If not specified current date will be considered.") @Valid @RequestParam(value = "date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date | ||
) { | ||
getRequest().ifPresent(request -> { | ||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { | ||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { | ||
String exampleString = "{ \"longDescription\" : \"longDescription\", \"primeur\" : true, \"image\" : { \"description\" : \"description\", \"url\" : \"url\" }, \"replica\" : true, \"shortDescription\" : \"shortDescription\", \"productionYear\" : \"productionYear\", \"title\" : \"title\", \"episodeNumber\" : \"episodeNumber\", \"people\" : [ { \"name\" : \"name\" }, { \"name\" : \"name\" } ], \"dateTimes\" : { \"duration\" : \"duration\", \"startTime\" : \"startTime\", \"endTime\" : \"endTime\" }, \"isLive\" : true, \"hasSubtitle\" : true, \"longHtmlDesciption\" : \"longHtmlDesciption\", \"adultWarning\" : true, \"geoBlocked\" : true }"; | ||
ApiUtil.setExampleResponse(request, "application/json", exampleString); | ||
break; | ||
} | ||
} | ||
}); | ||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); | ||
|
||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
srgssr-api/src/main/java/ch/srgssr/epg/api/BusinessUnitApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ch.srgssr.epg.api; | ||
|
||
import org.springframework.format.annotation.DateTimeFormat; | ||
import ch.srgssr.epg.api.Error; | ||
import java.time.LocalDate; | ||
import ch.srgssr.epg.api.Program; | ||
|
||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.CookieValue; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
|
||
import javax.validation.constraints.*; | ||
import javax.validation.Valid; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import javax.annotation.Generated; | ||
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-10-31T10:50:32.787731300+01:00[Europe/Zurich]") | ||
@Controller | ||
@RequestMapping("${openapi.sRGSSREPGV3.base-path:/epg/v3}") | ||
public class BusinessUnitApiController implements BusinessUnitApi { | ||
|
||
private final NativeWebRequest request; | ||
|
||
@Autowired | ||
public BusinessUnitApiController(NativeWebRequest request) { | ||
this.request = request; | ||
} | ||
|
||
@Override | ||
public Optional<NativeWebRequest> getRequest() { | ||
return Optional.ofNullable(request); | ||
} | ||
|
||
} |
Oops, something went wrong.