Skip to content

Commit

Permalink
Fix apiture#24 - link to correct JSON Schema version for OAS 3.0.x
Browse files Browse the repository at this point in the history
Fixed #36 - Allow for no security requirements object on an operaetion
  • Loading branch information
DavidBiesack committed Apr 22, 2024
1 parent f84f0b6 commit 1a8a201
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class Converter {
continue;
}
const operation = paths[path][op];
const sec = operation?.security as object[];
const sec = (operation?.security || []) as object[];
sec.forEach((s) => {
const requirement = s?.[schemeName] as string[];
if (requirement) {
Expand Down
3 changes: 2 additions & 1 deletion test/converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ describe('resolver test suite', () => {
const scopes = converted.components.securitySchemes.accessToken.flows.authorizationCode.scopes;
expect(scopes['scope1']).toEqual('Allow the application to access your personal profile data.');
expect(scopes['scope3']).toEqual(`TODO: describe the 'scope3' scope`);
const unauthOp = (converted.paths['/users/{appId}/open-preferences'] as object)['get'];
expect(unauthOp['security']).toBeFalsy();
done();
});
});
Expand Down Expand Up @@ -950,4 +952,3 @@ test('contentMediaType with existing unexpected format', (done) => {
// TODO how to check that Converter logged to console.warn ?
done();
});

60 changes: 56 additions & 4 deletions test/data/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.1.0
info:
title: Transactions
title: Application Preferences (Example OpenAPI)
description: ...
version: 0.1.2
contact:
Expand All @@ -21,7 +21,7 @@ paths:
parameters:
- $ref: '#/components/parameters/appIdPathParam'
get:
summary: Return preferences for a application
summary: Return preferences for an application
description: ...
operationId: listPreferences
tags:
Expand Down Expand Up @@ -66,7 +66,7 @@ paths:
application/pdf:
schema:
type: string
contentMediaType: application/json
contentMediaType: application/pdf
contentEncoding: base64
maxLength: 5000000
'400':
Expand All @@ -92,6 +92,58 @@ paths:
- scope2
- scope3
- scope4
/users/{appId}/open-preferences:
parameters:
- $ref: '#/components/parameters/appIdPathParam'
get:
summary: Return public preferences for an application, without auth
description: ...
operationId: listPublicPreferences
tags:
- Preferences
parameters:
- name: categories
description: >-
Filter preferences to only those whose `category` is in this
pipe-separated list.
in: query
style: pipeDelimited
schema:
type: array
minItems: 1
maxItems: 16
examples:
- - Presentation
- - Presentation
- Notifications
items:
type: string
- name: type
description: >-
Filter preferences only those whose `type` is in this pipe-separated
list.
in: query
style: pipeDelimited
schema:
type: array
minItems: 1
maxItems: 4
uniqueItems: true
items:
type: string
responses:
'200':
description: OK.
content:
application/json:
schema:
$ref: '#/components/schemas/preferences'
application/pdf:
schema:
type: string
contentMediaType: application/pdf
contentEncoding: base64
maxLength: 5000000
components:
securitySchemes:
accessToken:
Expand Down Expand Up @@ -437,4 +489,4 @@ components:
minlength is for no milliseconds, such as
'2021-10-30T19:06:00Z'
maxLength is for '.' plus up to 9 digits for milliseconds,
such as '2021-10-30T19:06:04.999000999Z'
such as '2021-10-30T19:06:04.999000999Z'

0 comments on commit 1a8a201

Please sign in to comment.