-
Notifications
You must be signed in to change notification settings - Fork 26
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 #33 from vitorAzevedo09/ht/correting-routes-url-sw…
…agger Ht/correting routes url swagger
- Loading branch information
Showing
6 changed files
with
239 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,27 @@ import ( | |
"golang.org/x/oauth2" | ||
) | ||
|
||
// @title Faladev API | ||
// @version 1.0 | ||
// @description Esta é uma API exemplo do Faladev, que integra com o Google Calendar e o Gmail. | ||
// @termsOfService http://swagger.io/terms/ | ||
|
||
// @contact.name Suporte da API Faladev | ||
// @contact.url http://www.faladev.com/support | ||
// @contact.email [email protected] | ||
|
||
// @license.name Apache 2.0 | ||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html | ||
|
||
// @host localhost:8080 | ||
// @BasePath / | ||
|
||
// @securityDefinitions.oauth2 OAuth2 | ||
// @securityDefinitions.oauth2.description OAuth2 authorization for accessing the API | ||
// @securityDefinitions.oauth2.flow accessCode | ||
|
||
// @externalDocs.description OpenAPI Specification | ||
// @externalDocs.url https://swagger.io/resources/open-api/ | ||
func main() { | ||
|
||
log.SetOutput(os.Stdout) | ||
|
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 |
---|---|---|
|
@@ -9,150 +9,163 @@ const docTemplate = `{ | |
"info": { | ||
"description": "{{escape .Description}}", | ||
"title": "{{.Title}}", | ||
"contact": {}, | ||
"termsOfService": "http://swagger.io/terms/", | ||
"contact": { | ||
"name": "Suporte da API Faladev", | ||
"url": "http://www.faladev.com/support", | ||
"email": "[email protected]" | ||
}, | ||
"license": { | ||
"name": "Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/event-handler": { | ||
"post": { | ||
"description": "Handles event creation, guest addition, email sending, and redirects to Google Meet link.", | ||
"/": { | ||
"get": { | ||
"description": "Renders the form.html page to display user information form.", | ||
"produces": [ | ||
"text/html" | ||
], | ||
"summary": "Render form page", | ||
"responses": { | ||
"200": { | ||
"description": "HTML content of the form page", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/callback": { | ||
"get": { | ||
"description": "Exchange code for token and save it", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Handle event creation and interaction", | ||
"summary": "Handle OAuth2 callback", | ||
"parameters": [ | ||
{ | ||
"type": "string", | ||
"description": "Name of the student", | ||
"name": "name", | ||
"in": "formData", | ||
"required": true | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Email of the student", | ||
"name": "email", | ||
"in": "formData", | ||
"description": "State token", | ||
"name": "state", | ||
"in": "query", | ||
"required": true | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Phone number of the student", | ||
"name": "phone", | ||
"in": "formData", | ||
"description": "Authorization code", | ||
"name": "code", | ||
"in": "query", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"303": { | ||
"description": "Redirects to Google Meet link", | ||
"schema": { | ||
"type": "string" | ||
} | ||
"description": "Redirects to /" | ||
}, | ||
"400": { | ||
"description": "No Google Meet link available or other errors", | ||
"description": "State token doesn't match", | ||
"schema": { | ||
"$ref": "#/definitions/handlers.ErrorResponse" | ||
"$ref": "#/definitions/http.ErrorResponse" | ||
} | ||
}, | ||
"500": { | ||
"description": "Internal server error", | ||
"schema": { | ||
"$ref": "#/definitions/handlers.ErrorResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/form": { | ||
"get": { | ||
"description": "Renders the form.html page to display user information form.", | ||
"produces": [ | ||
"text/html" | ||
], | ||
"summary": "Render form page", | ||
"responses": { | ||
"200": { | ||
"description": "HTML content of the form page", | ||
"description": "Unable to retrieve or save token", | ||
"schema": { | ||
"type": "string" | ||
"$ref": "#/definitions/http.ErrorResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/oauth/callback": { | ||
"get": { | ||
"description": "Exchange code for token and save it", | ||
"/event": { | ||
"post": { | ||
"description": "Handles event creation, guest addition, email sending, and redirects to Google Meet link.", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Handle OAuth2 callback", | ||
"summary": "Handle event creation and interaction", | ||
"parameters": [ | ||
{ | ||
"type": "string", | ||
"description": "State token", | ||
"name": "state", | ||
"in": "query", | ||
"description": "Name of the student", | ||
"name": "name", | ||
"in": "formData", | ||
"required": true | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Authorization code", | ||
"name": "code", | ||
"in": "query", | ||
"description": "Email of the student", | ||
"name": "email", | ||
"in": "formData", | ||
"required": true | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Phone number of the student", | ||
"name": "phone", | ||
"in": "formData", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"303": { | ||
"description": "Redirects to /" | ||
"description": "Redirects to Google Meet link", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
"400": { | ||
"description": "State token doesn't match", | ||
"description": "No Google Meet link available or other errors", | ||
"schema": { | ||
"$ref": "#/definitions/handlers.ErrorResponse" | ||
"$ref": "#/definitions/http.ErrorResponse" | ||
} | ||
}, | ||
"500": { | ||
"description": "Unable to retrieve or save token", | ||
"description": "Internal server error", | ||
"schema": { | ||
"$ref": "#/definitions/handlers.ErrorResponse" | ||
"$ref": "#/definitions/http.ErrorResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"handlers.ErrorResponse": { | ||
"http.ErrorResponse": { | ||
"type": "object", | ||
"properties": { | ||
"error": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"externalDocs": { | ||
"description": "OpenAPI Specification", | ||
"url": "https://swagger.io/resources/open-api/" | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "", | ||
Host: "", | ||
BasePath: "", | ||
Version: "1.0", | ||
Host: "localhost:8080", | ||
BasePath: "/", | ||
Schemes: []string{}, | ||
Title: "", | ||
Description: "", | ||
Title: "Faladev API", | ||
Description: "Esta é uma API exemplo do Faladev, que integra com o Google Calendar e o Gmail.", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
|
Oops, something went wrong.