Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIKIT-2575: Console not rendering when exchange modules are used #542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class ConsoleHandler implements MessageProcessor
private static final String DEFAULT_API_RESOURCES_PATH = DEFAULT_API_FOLDER + "/";
private static final String FILE_SEPARATOR_REGEX = File.separator.equals("\\") ? "\\\\" : "/";
private static final String RAML_QUERY_STRING = "raml";
private static final String EXCHANGE_MODULES = "exchange_modules";
private List<String> acceptedClasspathResources;
private String cachedIndexHtml;
private String embeddedConsolePath;
Expand Down Expand Up @@ -376,6 +377,10 @@ private URL readFromRamlRef(String ref) {
}

private URL readFromPath(String resourcePath) {
int lastIndexOfExchangeModules = resourcePath.lastIndexOf(EXCHANGE_MODULES);
if (lastIndexOfExchangeModules > 0) {
return Thread.currentThread().getContextClassLoader().getResource(resourcePath.substring(lastIndexOfExchangeModules));
}
Path root = Paths.get("/");
Path relativePath = Paths.get(embeddedConsolePath, "/" + DEFAULT_API_FOLDER);
Path path = Paths.get(resourcePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public void getResource3() throws Exception
@Test
public void apiResources()
{
String[] apiResources = new String[]{"exchange_modules/library1.raml","exchange_modules/library2.raml","/exchange_modules/library3.raml"};
String[] apiResources = new String[]{"exchange_modules/library1.raml","exchange_modules/library2.raml","/exchange_modules/library3.raml",
"/exchange_modules/standard-types/exchange_modules/shared-types/library-shared.raml",
"/exchange_modules/standard-types/exchange_modules/shared-types/exchange_modules/traits/examples/error/error-400-example.json"};

for (String resource: apiResources){
given().header("Accept", "*/*")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 Library

usage: Shared Library 1

types:
Standard-datetime:
type: datetime
format: rfc3339
example: 2016-02-28T16:41:41.0+01:00
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#%RAML 1.0 DataType

usage: Standard error message

type: object
displayName: Standard Error Message
properties:
code:
type: number
format: int32
name:
type: string
reason:
type: string
message:
type: string
trace_id:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#%RAML 1.0 Library

usage: Standard Library 1

uses:
SharedTypes: exchange_modules/shared-types/library-shared.raml

annotationTypes:
deprecated:
allowedTargets: [API, Resource, Method]
properties:
description:
type: string
required: false
endOfService:
type: SharedTypes.Standard-datetime
required: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"code" : 123,
"name" : "APIKIT_ERROR",
"reason" : "None",
"message" : "Bad Request",
"trace_id" : "548512ABC"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#%RAML 1.0 Trait

usage: Trait 400 error

uses:
SharedTypes: exchange_modules/shared-types/library-shared.raml

responses:
400:
description: Bad Request
body:
application/json:
type: !include exchange_modules/standard-datatype/datatype-standard-error-message.raml
example: !include examples/error/error-400-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ uses:
library1: exchange_modules/library1.raml
library2: exchange_modules/library2.raml
library3: /exchange_modules/library3.raml
standardLibrary: exchange_modules/standard-types/library-standard.raml

traits:
has400: !include exchange_modules/traits/trait-has400.raml

/resource1:
get:
Expand Down