Skip to content

Remove Stencil from Kitura-OpenAPI#19

Merged
DunnCoding merged 2 commits intoKitura:masterfrom
DunnCoding:issue.16
Jan 30, 2019
Merged

Remove Stencil from Kitura-OpenAPI#19
DunnCoding merged 2 commits intoKitura:masterfrom
DunnCoding:issue.16

Conversation

@DunnCoding
Copy link
Copy Markdown
Contributor

@DunnCoding DunnCoding commented Jan 29, 2019

This PR aims to remove Kitura Stencil as a dependency from Kitura OpenAPI.

I've used the FileManager to gain access to the files, reading the contents and using replacingOccurrences(of:with:) to update the contents before writing.

I've also created another file, template.html, which will is the source we read from and then write to index.html which is the page we serve.

A tearDown() function was also added to the tests. This is to ensure after each run of the tests we delete the index.html.

Tested on both macOS and Linux.

Copy link
Copy Markdown
Contributor

@djones6 djones6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, barring a few nit-picky comments

public class KituraOpenAPI {
public static var defaultConfig = KituraOpenAPIConfig(apiPath: "/openapi", swaggerUIPath: "/openapi/ui")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - whitespace

sourcesDirectory += "/swaggerui/index.html"
let fileURL = URL(fileURLWithPath: sourcesDirectory)
do {
try "".write(to: fileURL, atomically: true, encoding: .utf8)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not delete the destination file instead?

if let response = response {
if let wrappedhtml = try? response.readString() {
if let html = wrappedhtml {
print(html)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you didn't mean to leave this here...

@DunnCoding DunnCoding merged commit 8699a83 into Kitura:master Jan 30, 2019
@DunnCoding DunnCoding deleted the issue.16 branch January 30, 2019 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants