Skip to content

Commit

Permalink
first round
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Apr 12, 2024
1 parent 1ecf5c4 commit f5a96c6
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 339 deletions.
21 changes: 0 additions & 21 deletions SECURITY.md

This file was deleted.

12 changes: 6 additions & 6 deletions docs/Tutorials/OpenAPI/OpenAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pode has built-in support for converting your routes into OpenAPI 3.0 definition

The OpenApi module has been extended with many more functions, and some old ones have been improved.

For more detailed information regarding OpenAPI and Pode, please refer to [OpenAPI Specification and Pode](../OpenAPI/Specification/v3_0_3.md)
For more detailed information regarding OpenAPI and Pode, please refer to [OpenAPI Specification and Pode](../Specification/v3_0_3.md)

You can enable OpenAPI in Pode, and a straightforward definition will be generated. However, to get a more complex definition with request bodies, parameters, and response payloads, you'll need to use the relevant OpenAPI functions detailed below.

Expand Down Expand Up @@ -738,9 +738,9 @@ As JSON, this could look as follows:

OpenAPI 3.x provides several keywords which you can use to combine schemas. You can use these keywords to create a complex schema or validate a value against multiple criteria.

* oneOf validates the value against exactly one of the sub-schemas
* allOf validates the value against all the sub-schemas
* anyOf validates the value against any (one or more) of the sub-schemas
* oneOf - validates the value against exactly one of the sub-schemas
* allOf - validates the value against all the sub-schemas
* anyOf - validates the value against any (one or more) of the sub-schemas

You can use the [`Merge-PodeOAProperty`] will instead define a relationship between the properties.

Expand Down Expand Up @@ -772,7 +772,7 @@ As JSON, this could look as follows:
"oneOf": [
{
"type": "object",
` "properties": {
"properties": {
"userId": {
"type": "integer"
}
Expand Down Expand Up @@ -861,7 +861,7 @@ Add-PodeRoute -PassThru -Method Post -Path '/user' -ScriptBlock {
$responseMediaType = Get-PodeHeader -Name 'Accept'
switch ($contentType) {
'application/xml' {
$user = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$user = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $user = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $user = ConvertTo-Json $WebEvent.data }
Expand Down
10 changes: 5 additions & 5 deletions examples/PetStore/Petstore-openApi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$pet = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$pet = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $pet = ConvertTo-Json $WebEvent.data }
default {
Expand Down Expand Up @@ -318,7 +318,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$pet = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$pet = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $pet = ConvertTo-Json $WebEvent.data }
default {
Expand Down Expand Up @@ -534,7 +534,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$order = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$order = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $order = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $order = ConvertTo-Json $WebEvent.data }
Expand Down Expand Up @@ -627,7 +627,7 @@ Some useful links:
$responseMediaType = Get-PodeHeader -Name 'Accept'
switch ($contentType) {
'application/xml' {
$user = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$user = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $user = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $user = ConvertTo-Json $WebEvent.data }
Expand Down Expand Up @@ -788,7 +788,7 @@ Some useful links:
if (Test-User -Username $username) {
switch ($contentType) {
'application/xml' {
$user = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$user = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $user = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $user = ConvertTo-Json $WebEvent.data }
Expand Down
12 changes: 6 additions & 6 deletions examples/PetStore/Petstore-openApiMultiTag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$pet = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$pet = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $pet = ConvertTo-Json $WebEvent.data }
default {
Expand Down Expand Up @@ -322,7 +322,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$pet = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$pet = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $pet = ConvertTo-Json $WebEvent.data }
default {
Expand Down Expand Up @@ -538,7 +538,7 @@ Some useful links:
$contentType = Get-PodeHeader -Name 'Content-Type'
switch ($contentType) {
'application/xml' {
$order = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$order = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $order = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $order = ConvertTo-Json $WebEvent.data }
Expand Down Expand Up @@ -631,7 +631,7 @@ Some useful links:
$responseMediaType = Get-PodeHeader -Name 'Accept'
switch ($contentType) {
'application/xml' {
$user = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$user = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $user = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $user = ConvertTo-Json $WebEvent.data }
Expand Down Expand Up @@ -792,7 +792,7 @@ Some useful links:
if (Test-User -Username $username) {
switch ($contentType) {
'application/xml' {
$user = ConvertFrom-PodeXML -node $WebEvent.data | ConvertTo-Json
$user = ConvertFrom-PodeXml -node $WebEvent.data | ConvertTo-Json
}
'application/json' { $user = ConvertTo-Json $WebEvent.data }
'application/x-www-form-urlencoded' { $user = ConvertTo-Json $WebEvent.data }
Expand Down Expand Up @@ -862,7 +862,7 @@ Some useful links:



#$r= ConvertFrom-PodeXML -node $xmlDoc
#$r= ConvertFrom-PodeXml -node $xmlDoc

#$pet=$r |convertto-json

Expand Down
84 changes: 0 additions & 84 deletions examples/async-rest.ps1

This file was deleted.

36 changes: 0 additions & 36 deletions examples/async-tasks.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion examples/logging.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else {
# or just:
# Import-Module Pode

$LOGGING_TYPE = 'custom' # Terminal, File, Custom
$LOGGING_TYPE = 'terminal' # Terminal, File, Custom

# create a server, and start listening on port 8085
Start-PodeServer {
Expand Down
2 changes: 1 addition & 1 deletion examples/web-auth-basic.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Invoke-RestMethod -Uri http://localhost:8085/users -Method Post -Headers @{ Auth
Start-PodeServer -Threads 2 {

# listen on localhost:8085
Add-PodeEndpoint -Address local -Port 8085 -Protocol Http
Add-PodeEndpoint -Address localhost -Port 8085 -Protocol Http

# request logging
New-PodeLoggingMethod -Terminal -Batch 10 -BatchTimeout 10 | Enable-PodeRequestLogging
Expand Down
20 changes: 10 additions & 10 deletions examples/web-rest-openapi-shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ Start-PodeServer {

New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging

Enable-PodeOpenApi -Title 'OpenAPI Example' -RouteFilter '/api/*' -RestrictRoutes
Enable-PodeOpenApiViewer -Type Swagger
Enable-PodeOpenApiViewer -Type ReDoc
Enable-PodeOpenApiViewer -Type RapiDoc
Enable-PodeOpenApiViewer -Type StopLight
Enable-PodeOpenApiViewer -Type Explorer
Enable-PodeOpenApiViewer -Type RapiPdf
Enable-PodeOpenApi -Title 'OpenAPI Example' -RouteFilter '/api/*' -RestrictRoutes
Enable-PodeOpenApiViewer -Type Swagger
Enable-PodeOpenApiViewer -Type ReDoc
Enable-PodeOpenApiViewer -Type RapiDoc
Enable-PodeOpenApiViewer -Type StopLight
Enable-PodeOpenApiViewer -Type Explorer
Enable-PodeOpenApiViewer -Type RapiPdf

Enable-PodeOpenApiViewer -Type Bookmarks -Path '/docs'

Enable-PodeOpenApiViewer -Editor
Enable-PodeOpenApiViewer -Bookmarks


New-PodeAuthScheme -Basic | Add-PodeAuth -Name 'Validate' -Sessionless -ScriptBlock {
Expand Down Expand Up @@ -48,10 +50,8 @@ Start-PodeServer {
ConvertTo-PodeOAParameter -In Path |
Add-PodeOAComponentParameter -Name 'UserId'


Add-PodeAuthMiddleware -Name AuthMiddleware -Authentication Validate -Route '/api/*'


Add-PodeRoute -Method Get -Path '/api/resources' -EndpointName 'user' -ScriptBlock {
Write-PodeJsonResponse -Value @{ Name = 'Rick'; UserId = 123 }
} -PassThru |
Expand Down
2 changes: 1 addition & 1 deletion examples/web-rest-openapi-simple.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Start-PodeServer {
Enable-PodeOpenApi -Title 'OpenAPI Example' -RouteFilter '/api/*' -RestrictRoutes
Enable-PodeOpenApiViewer -Type Swagger -DarkMode
Enable-PodeOpenApiViewer -Type ReDoc
Enable-PodeOpenApiViewer -Type Bookmarks -Path '/docs'
Enable-PodeOpenApiViewer -Bookmarks -Path '/docs'

Add-PodeRoute -Method Get -Path '/api/resources' -EndpointName 'user' -ScriptBlock {
Set-PodeResponseStatus -Code 200
Expand Down
16 changes: 8 additions & 8 deletions examples/web-rest-openapi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Start-PodeServer {
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging

Enable-PodeOpenApi -Title 'OpenAPI Example' -RouteFilter '/api/*' -RestrictRoutes
Enable-PodeOpenApiViewer -Type Swagger -Path '/docs/swagger'
Enable-PodeOpenApiViewer -Type ReDoc -Path '/docs/redoc'
Enable-PodeOpenApiViewer -Type RapiDoc -Path '/docs/rapidoc'
Enable-PodeOpenApiViewer -Type StopLight -Path '/docs/stoplight'
Enable-PodeOpenApiViewer -Type Explorer -Path '/docs/explorer'
Enable-PodeOpenApiViewer -Type RapiPdf -Path '/docs/rapipdf'

Enable-PodeOpenApiViewer -Type Bookmarks -Path '/docs'
Enable-PodeOpenApiViewer -Type Swagger -Path '/docs/swagger'
Enable-PodeOpenApiViewer -Type ReDoc -Path '/docs/redoc'
Enable-PodeOpenApiViewer -Type RapiDoc -Path '/docs/rapidoc'
Enable-PodeOpenApiViewer -Type StopLight -Path '/docs/stoplight'
Enable-PodeOpenApiViewer -Type Explorer -Path '/docs/explorer'
Enable-PodeOpenApiViewer -Type RapiPdf -Path '/docs/rapipdf'
Enable-PodeOpenApiViewer -Editor -Path '/docs/editor'
Enable-PodeOpenApiViewer -Bookmarks -Path '/docs'

New-PodeAuthScheme -Basic | Add-PodeAuth -Name 'Validate' -Sessionless -ScriptBlock {
return @{
Expand Down
4 changes: 2 additions & 2 deletions src/Misc/default-doc-bookmarks.html.pode
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@
</div>
<!-- Tab content -->
<div id="JSON" class="tabcontent">
<pre><code id="jsonCode" class="json">Loading JSON content...<</code></pre>
<pre><code id="jsonCode" class="json">Loading JSON content...</code></pre>
</div>
<div id="YAML" class="tabcontent" style="display:none">
<pre><code id="yamlCode" class="yaml">Loading YAML content...<</code></pre>
<pre><code id="yamlCode" class="yaml">Loading YAML content...</code></pre>
</div>
<footer style='text-align: center;
width: 100%;
Expand Down
Loading

0 comments on commit f5a96c6

Please sign in to comment.