-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
ace24e5
commit 14d8480
Showing
20 changed files
with
1,293 additions
and
49 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
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
54 changes: 54 additions & 0 deletions
54
...les/apim-adapter/src/main/java/com/axway/apim/api/specification/GraphqlSpecification.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,54 @@ | ||
package com.axway.apim.api.specification; | ||
|
||
import com.axway.apim.api.API; | ||
import com.axway.apim.lib.error.AppException; | ||
import graphql.schema.idl.SchemaParser; | ||
import graphql.schema.idl.errors.SchemaProblem; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
public class GraphqlSpecification extends APISpecification { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(GraphqlSpecification.class); | ||
|
||
@Override | ||
public byte[] getApiSpecificationContent() { | ||
return this.apiSpecificationContent; | ||
|
||
} | ||
|
||
@Override | ||
public void updateBasePath(String basePath, String host) { | ||
// Not required | ||
} | ||
|
||
@Override | ||
public void configureBasePath(String backendBasePath, API api) throws AppException { | ||
// Not required | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public APISpecType getAPIDefinitionType() throws AppException { | ||
return APISpecType.GRAPHQL; | ||
} | ||
|
||
@Override | ||
public boolean parse(byte[] apiSpecificationContent){ | ||
this.apiSpecificationContent = apiSpecificationContent; | ||
SchemaParser schemaParser = new SchemaParser(); | ||
try { | ||
schemaParser.parse(new ByteArrayInputStream(apiSpecificationContent)); | ||
return true; | ||
}catch (SchemaProblem schemaProblem){ | ||
LOG.error("Unable to parse graphql", schemaProblem); | ||
return false; | ||
} | ||
} | ||
} |
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
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
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
20 changes: 20 additions & 0 deletions
20
...m-adapter/src/test/java/com/axway/apim/api/specification/APISpecificationGraphqlTest.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,20 @@ | ||
package com.axway.apim.api.specification; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
|
||
public class APISpecificationGraphqlTest { | ||
|
||
private static final String testPackage = "/com/axway/apim/adapter/spec"; | ||
|
||
@Test | ||
public void isGraphqlSpecificationBasedOnFile() throws IOException { | ||
byte[] content = IOUtils.toByteArray(this.getClass().getResourceAsStream(testPackage + "/starwars.graphqls")); | ||
APISpecification apiDefinition = APISpecificationFactory.getAPISpecification(content, testPackage + "/starwars.graphqls", "Starwars"); | ||
// Check, if the specification has been identified as a WSDL | ||
Assert.assertTrue(apiDefinition instanceof GraphqlSpecification); | ||
} | ||
} |
Oops, something went wrong.