Skip to content

Commit

Permalink
fixes #622 - Process application/jose content-types to generate examp…
Browse files Browse the repository at this point in the history
…les and schema
  • Loading branch information
mrin9 committed Feb 23, 2022
1 parent 8ff2bb0 commit 179f5e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ export default class ApiRequest extends LitElement {
let schemaAsObj;
let reqBodyExamples = [];

if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text')) {
if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text') || this.selectedRequestBodyType.includes('jose')) {
// Generate Example
if (reqBody.mimeType === this.selectedRequestBodyType) {
reqBodyExamples = generateExample(
Expand Down Expand Up @@ -625,7 +625,7 @@ export default class ApiRequest extends LitElement {
}

// Generate Schema
if (reqBody.mimeType.includes('json') || reqBody.mimeType.includes('xml') || reqBody.mimeType.includes('text')) {
if (reqBody.mimeType.includes('json') || reqBody.mimeType.includes('xml') || reqBody.mimeType.includes('text') || this.selectedRequestBodyType.includes('jose')) {
schemaAsObj = schemaInObjectNotation(reqBody.schema, {});
if (this.schemaStyle === 'table') {
reqBodySchemaHtml = html`
Expand Down Expand Up @@ -669,7 +669,7 @@ export default class ApiRequest extends LitElement {
</div>
${this.request_body.description ? html`<div class="m-markdown" style="margin-bottom:12px">${unsafeHTML(marked(this.request_body.description))}</div>` : ''}
${(this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text'))
${(this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text') || this.selectedRequestBodyType.includes('jose'))
? html`
<div class="tab-panel col" style="border-width:0 0 1px 0;">
<div class="tab-buttons row" @click="${(e) => { if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; } }}">
Expand Down
9 changes: 9 additions & 0 deletions src/utils/schema-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,15 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
exampleValue,
});
}
} else if (mimeType?.toLowerCase().includes('jose')) {
finalExamples.push({
exampleId: 'Example',
exampleSummary: 'Base64 Encoded',
exampleDescription: '',
exampleType: mimeType,
exampleValue: schema.pattern || 'bXJpbg==',
exampleFormat: 'text',
});
} else {
finalExamples.push({
exampleId: 'Example',
Expand Down

0 comments on commit 179f5e8

Please sign in to comment.