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

OpenApi ContentMedia Array and Properties #1205

Closed
mdaneri opened this issue Dec 18, 2023 · 0 comments
Closed

OpenApi ContentMedia Array and Properties #1205

mdaneri opened this issue Dec 18, 2023 · 0 comments
Milestone

Comments

@mdaneri
Copy link
Contributor

mdaneri commented Dec 18, 2023

Describe the Feature

Today, Pode allows us to define ContentMedia as a Hashtable. This is enough to represent a simple ContentMedia but not one with arrays or special properties.
Another feature is hiding the complexity of the upload definition and the differences between OpenAPI 3.0.x and 3.1.x

New Functions

New-PodeOAContentMediaType

Parameters

-MediaType
An array of strings specifying the media types to be defined. Media types should conform to standard MIME types (e.g., 'application/json', 'image/png'). The function validates these media types against a regular expression to ensure they are properly formatted.

-Content
The content definition for the media type. This could be an object representing the structure of the content expected for the specified media types.

-Array
A switch parameter, used in the 'Array' parameter set, to indicate that the content should be treated as an array.

-UniqueItems
A switch parameter, used in the 'Array' parameter set, to specify that items in the array should be unique.

-MinItems
Used in the 'Array' parameter set to specify the minimum number of items that should be present in the array.

-MaxItems
Used in the 'Array' parameter set to specify the maximum number of items that should be present in the array.

-Title
Used in the 'Array' parameter set to provide a title for the array content.

-Upload
If provided configure the media for an upload changing the result based on the OpenApi version

-ContentEncoding
Define the content encoding for upload (Default Binary)

-PartContentMediaType
Define the content encoding for multipart upload

Examples

New-PodeOAContentMediaType -MediaType 'image/jpeg','image/png' -Content (
New-PodeOAStringProperty -Format binary)
# multiple, specific media types may be specified:
requestBody:
  content:
      # a binary file of type png or jpeg
    'image/jpeg':
      schema:
        type: string
        format: binary
    'image/png':
      schema:
        type: string
        format: binary
 Set-PodeOARequest -RequestBody  (
  New-PodeOARequestBody -Content (
    New-PodeOAContentMediaType -MediaType 'multipart/form-data' -Content (
      New-PodeOAStringProperty -name 'id' -format 'uuid' |
          New-PodeOAObjectProperty -name 'address' -NoProperties |
          New-PodeOAStringProperty -name 'children' -array |
          New-PodeOASchemaProperty -Name 'addresses' -ComponentSchema 'Address' -Array |
          New-PodeOAObjectProperty
      )
    )
 )
requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          id:
            type: string
            format: uuid
          address:
            # default Content-Type for objects is `application/json`
            type: object
            properties: {}
          profileImage:
            # default Content-Type for string/binary is `application/octet-stream`
            type: string
            format: binary
          children:
            # default Content-Type for arrays is based on the `inner` type (text/plain here)
            type: array
            items:
              type: string
          addresses:
            # default Content-Type for arrays is based on the `inner` type (object shown, so `application/json` in this example)
            type: array
            items:
              type: '#/components/schemas/Address'
@mdaneri mdaneri changed the title OpenApi ContentMedia Array and properties OpenApi ContentMedia Array and Properties Dec 18, 2023
@Badgerati Badgerati added this to the 2.10.0 milestone Apr 13, 2024
Badgerati pushed a commit that referenced this issue Apr 14, 2024
* fixes

* replace [void] with $null =

* [switch] vs bool

* minor fixes

* remove Pode.sln

* fixes

Fix an issue with YAML and http string
fix an issue with multiple objects and allOf/oneOf/anyOff
fix #1177 When the Access-Control-Allow-Headers is *, the Authorization has to be explicitly  listed

Still some issues with Test-PodeOARequestSchema when allOf is present

* fix to Test-PodeOARequestSchema

* Set-PodeSecurityAccessControl headers and methods auto-popuate

Set-PodeSecurityAccessControl now can automatically populate headers and methods. No more '*' are required

* code compliance

* added some references to the help

* fix an issue with merge and objects

* Fix $Return

* first openapitest

* additional tests

* Additional tests

* new tests and buf fixes

* fixes and tests

* additional tests

* Update tests to be Pester 5.5 compatible

Updated all tests to be 5.x compatible
Upgrade Pester to 5.5
additional OpenApi tests
bug fixes

* Update OpenAPI.md

* Update OpenAPI.md

* documentation 1st addition

* Documentation and fixes

Test [order] on OpenAPI fixed
Added assembly version to C# DLL
Added OpenAPI 3.0.3 doc - work in progress

* docs and cmdlet changes

* Add-PodeOAInfo test fix

* new openapi auth

Add OAuth2 OpenAPI support
Fix #1182
added new API documentation

* fix OpenApi Authentication

* fixes

* fixes

* OpenApi doc addiction

* reorg properties

* Add exemples

* fix examples

* examples property fixes

* improvements

* added aditional PodeOAParam

* Support for .Net8 and PWSH 7.4

Added support for pwsh 7.4 and .Net8
Added .Net8 DLL build
Fixes to ConvertTo-PodeOAParameter
Pester fixes

* Added support for RFC1866

* Added support for encoding

Added support for OpenApi RequestBody encoding definition #1190
Fix an issue with YAML conversion where a number is converted to string
Additional OpenApi documentation related to encoding

* fixes

* header response support

* Default OAproperty fix

* report pwsh version during build

* fix an compatibility with pwsh<7.3

* Create PSScriptAnalyzer.yml

* powershell test

* build fix for desktop pwsh

* upgrade invokeBuild

* .

* .

* VSCode made me crazy

* .

* added pwsh 7.4

* Add pwsh version check

* update actions to v3

* changed version on pode.build

* try pwsh 7.4 test

* modified:   .github/workflows/ci-pwsh7_4.yml

* added macos to 7.4

* fix mac

* .

* .

* add chmod

* added 7.3 test

* fixes

* .

* fix version print

* new corner cases

* New Features and 3 new cmdlets

Added support for File Uploads #1160
Added support for Response Links #1158  (Add-PodeOAResponseLink)
Added support for Callbacks #1157 (Add-PodeOACallBacksResponse) (Add-PodeOACallBacks)

* fix Cmdlet names

* various improvements

* Added new Route OAResponses param

* Add New-PodeOAMediaContentType

* fixes and improvements

* fix openapi test

* fix a text replacement went wrong

* Doc changes

* change to  Test-PodeOAJsonSchemaCompliance

* fix Petstore

* test fix

* remove default response option

* Added support for OA3.1

Open API 3.1 #1193
Fix an issue with example accepting only string

* Added components for links and callback

* fix content link,callback

* Fix test

* change default responses

* Added support for route auth and anon

* Improved XML elements parameters

* fix openapi test

* fix openapi test syntax error

* added documentation + fix -AdditionalProperties

* fix an response header issue. cleanup PetStore

* Petstore Sample+ convert xml to hash

* fixes

* add new New-PodeOAMultiTypeProperty for 3.1 multitype support

* petstore

* completed petstore sample

* Fix server test

* Review OpenAPI Doc and fix some property name

* doc changes

* docs update

* Split OpenApi to 3 files

* first drop for multi openapi definitions

* cleanup parameters + fixes

* OpenApi support for Path Server + fixes

OpenApi support for Path Servers #1201
OpenApi documentation update
fixes

* doc fix

* Change $OAtag to $SpecTag

* Added SpeTag to public OpenaAPI

* Multi OpenApi documents support

Now is possible to define multiple OpenAPI documents with different characteristic and assign it to different path

* Change property name from SpecTag to DefinitionTag

* Add help to Add-PodeComponentGroup

* Add webhook and fix headers reference

* fix header test

* Add a new server configuration DefaultOADefinitionTag

* Fix tests

* fixes

* fixes

* fix parameters  help test

* test fixes + Select-PodeOADefinition use a stack

* fix openapi test

* documentation update

* fix the restart server

* fix server test

* new docs

* minor update

* fix openapi test

* swagger pump to last version

* State OpenAPI definition at server start

New Features addressed
- #1193
- #1203
- #1205
- #1209
- #1190
- #1160
- #1157
- #1201
- #1213
- #1206
- #1204
- #1212
- #1202
- #1168
- #1212
- #1218
- #1219
- #1157
- #1211
- #1220
- #1164
- #1210
- #1215
- #1214
- #1216
- #1224
- #1225

* fix an OpenAPI spec Tag issue + build improvements

* Add support for recursive components

FIx #1088

* fix OpenAPI test

* fix an issue with PodeOAViewer and endpoints

* fix pode.build InstallCurrentUser

* Fix a version comparison issue with DLL

* fix an issue with testing

* fixes

* Add Swagger-Editor as OpenAPI editor

* added Enable-PodeOAViewer  -Editor documentation

* fix a wrong function call

* set default path for  Enable-PodeOAViewer

* Added authentication to Enable-PodeOpenApi and Enable-PodeOAViewer

* fixes

* Update license.txt

* update license year

* Invoke-PodeAuthValidation parallel validation with PowershellS >7.x

* Badgerati recommendation

* Badgerati recommendation

* fix tests

* new static web example

* .

* Matthew recommendations

+ new PrivateOpenAPI test
+ added comments and headers to some private OpenAPI functions
+ fix a bug with New-PodeOResponseInternal OpenAPI `Description` response property

* review docs

* fixes

fix an issue with Test-PodeOAJsonSchemaCompliance relate to definition tags
add remove-module task to Pode.build.ps1
rename installcurrentuser to install-module in  Pode.build.ps1

* Update Security.ps1

fix to solve Access-Control-Allow-Methods requires all methods to be uppercase  requirement

* more headers and tests

* Documentation fixes

+ package support for Linux build

* more private/OpenAPI.ps1 tests and inline comments

* fix Initialize-OpenApiTable Tests on Pws 5.1, change default OAViewer path

* build cross-platform improvements

* fix the checksum issue on linux

* improved build clean

* Added a new build guide

* fix a workflow issue with versions

* additional comment and test to private/OpenApi.ps1

* move build.md under docs

* Move build.md to Getting-Started

* build.md added MacOS

* fix an issue with schema Validation when oneof and anyof is part of the schema

* Implement File Browsing feature #1237

* Fix the random file generator

* added -FileBrowser to Start-PodeStaticServer Add-PodeStaticRouteGroup

Start-PodeStaticServer Add-PodeStaticRouteGroup now have -FileBrowser  switch
New function `Write-PodeDirectoryResponse`
changed if else indentation for compliancy

* Code is working but test is failing

* Reorganize Write-PodeFileResponse

* FileBrowser and Default page fixes

Solve the issue with the static page and Default pages. Now the default page is loaded correctly with the right link
Cleanup folders check functions

* support for independent static paths

Now each static path is independent.
FileBrowser.ps1 sample implement 3 distinct routes with different settings

* Get-PodeRouteByUrl improvement

Now Get-PodeRouteByUrl is using a regex to find the right route solving the problem when path include *(/something/*/test) or a Path parameter like (/something/:mystuff/test)

* fix tests

* Added Mathew fix for static routes order + fix openapi auth with static route

* Address the problem with static path containing /*/ + some cleanup

New helper Get-PodeUrlPart to address url path with *
New internal function Write-PodeAttachmentResponseInternal used to replace internally the public Set-PodeResponseAttachment.
Set-PodeResponseAttachment now is calling Write-PodeAttachmentResponseInternal
Find-PodeStaticRoute now accept a new RequestUrl param that represent the user url ( to manage /*/ url)

* Fix an issue with public and Set-PodeResponseAttachment

* fix Write-PodeAttachmentResponseInternal

* added PSScriptAnalyzer.psd1 ExcludeRules = @('PSAvoidUsingCmdletAliases' ,'PSAvoidUsingPlainTextForPassword')

* add ConvertTo-PodeYamlInternal test and fix an issue with the conversion with -nonewline and array

* fix ConvertTo-PodeYamlInternal test

* fix spaces in  ConvertTo-PodeYamlInternal test

* Fix PodeSession tests `Should Throw` is not allowed in 5.5 `Should -Throw` is the right syntax

* .

* moved PSScriptAnalyzerSettings.psd1 to root

* PSScriptAnalyzer and Customizable Default Folder Paths

Enhancing Flexibility with Customizable Default Folder Paths in Pode #1243
Incorporate PSScriptAnalyzerSettings for Enhanced Code Quality #1244
+
Modified test script to be excluded by PSScriptAnalyzer
Implemented some of PSScriptAnalyzer recommendation
+
added multiple function headers

* GitHub Actions: Transitioning from Node 16 to Node 20

* Update PSScriptAnalyzer.yml

* rollback process{}

* Rollback the Pattern/Route logic

* Fix the issue with broswing a path with *
Added documentation for -FileBrowser feature

* Fix an issue when a default file(index.htm) is on root and -FileBrowser is used

* Move Write-PodeFileResponse internal call to Write-PodeFileResponseInternal

* fix a test issue

* fix an security issue durieng a pegasus scan

* Adding server.psd1 new properties documentation

* fix an issue withe external OpenAPI requests

* update github workflow

* fix a label for pwsh 7.5

* doc fixes

* workaround for https rest test with powershell 7.4.x

* cleanup

* change curl.exe to curl for linux compatibility

* fix test for linux and mac

* reinstate SkipCertificateCheck

* fix desktop

* restore Server.test.ps1

* new file:   .github/workflows/ci-pwsh7_2.yml
 	modified:   pode.build.ps1
 	modified:   src/Pode.psd1
 	modified:   src/Pode.psm1
 	modified:   src/Private/Server.ps1

* .

* .

* .

* .

* .

* .

* Create SECURITY.md

* Add Versioning functions

* .

* Update pode.build.ps1

* fix an issue with build

* fix build

* fix configuration.md

* Update StaticContent.md

* review-1

* docs update

* fix issues reported by  _Test

* Documentation fixes

* first round

* second round

* Third iteration

* Fix ConvertTo-PodeYamlInternal Tests
@github-project-automation github-project-automation bot moved this from Backlog to Done in 🚀 Pode Roadmap Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants