-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2043 from ayeshLK/2201.9.x-dev
[2201.9.x] Generate and host SwaggerUI for the generated OpenAPI specification as a built-in resource
- Loading branch information
Showing
12 changed files
with
292 additions
and
118 deletions.
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
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
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
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
69 changes: 69 additions & 0 deletions
69
native/src/main/java/io/ballerina/stdlib/http/api/HttpOASResource.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,69 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.ballerina.stdlib.http.api; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static io.ballerina.stdlib.http.api.HttpConstants.SINGLE_SLASH; | ||
|
||
/** | ||
* {@code HttpOASResource} is the super class for the service introspection resources. | ||
* | ||
* @since v2.11.2 | ||
*/ | ||
public abstract class HttpOASResource extends HttpResource { | ||
protected static final String RESOURCE_METHOD = "$get$"; | ||
|
||
protected HttpOASResource(HttpService httpService, String rel, String resourcePath) { | ||
String path = (httpService.getBasePath() + SINGLE_SLASH + resourcePath).replaceAll("/+", SINGLE_SLASH); | ||
httpService.addOasResourceLink("<" + path + ">;" + rel); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return String.format("%s%s", RESOURCE_METHOD, getResourceName()); | ||
} | ||
|
||
@Override | ||
public String getPath() { | ||
return String.format("%s%s", SINGLE_SLASH, getResourceName()); | ||
} | ||
|
||
@Override | ||
public List<String> getMethods() { | ||
return List.of(HttpConstants.HTTP_METHOD_GET); | ||
} | ||
|
||
@Override | ||
public List<String> getConsumes() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<String> getProduces() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
protected abstract String getResourceName(); | ||
|
||
public abstract byte[] getPayload(); | ||
|
||
public abstract String getContentType(); | ||
} |
Oops, something went wrong.