Skip to content

Commit

Permalink
Merge pull request ErikWittern#5 from jci-metasys/revertChanges
Browse files Browse the repository at this point in the history
Revert "upgrade httpsnippet dependency"
  • Loading branch information
michaelgwelch authored Sep 18, 2024
2 parents 612bf95 + 4ac1817 commit 54bd697
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 624 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.14.0-jci2] - 2024-09-05

- Update `httpsnippet` to `v3.0` to benefit from fixes in code snippets. For
example ensuring that double quotes in csharp examples are escaped properly.

## [0.14.0-jci1] - 2024-06-24

Changes since `0.14.0`:

- Add support for server variables when generating base url for code snippets.

[0.14.0-jci2]: https://github.com/jci-metasys/openapi-snippet/compare/v0.14.0-jci1...v0.14.0-jci2
[0.14.0-jci1]: https://github.com/jci-metasys/openapi-snippet/compare/v0.14.0...v0.14.0-jci1
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'use strict';

const OpenAPIToHar = require('./openapi-to-har.js');
const { HTTPSnippet, availableTargets } = require('httpsnippet');
const HTTPSnippet = require('httpsnippet');

/**
* Return snippets for endpoint identified using path and method in the given
Expand Down Expand Up @@ -147,7 +147,7 @@ const formatTarget = function (targetStr) {
const title = capitalizeFirstLetter(language);
let library = targetStr.split('_')[1];

const validTargets = availableTargets();
const validTargets = HTTPSnippet.availableTargets();
let validLanguage = false;
let validLibrary = false;
for (let i in validTargets) {
Expand Down
30 changes: 7 additions & 23 deletions openapi-to-har.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,8 @@ const createHarParameterObjects = function (
}

const objects = [];
if (style === null || style === undefined) {
style = getDefaultStyleForLocation(location);
}
if (explode === null || explode === undefined) {
explode = getDefaultExplodeForStyle(style);
}

style = style ?? getDefaultStyleForLocation(location);
explode = explode ?? getDefaultExplodeForStyle(style);

if (location === 'query' || location === 'cookie') {
const separator = getArrayElementSeparator(style);
Expand Down Expand Up @@ -271,18 +266,11 @@ const createHarParameterObjects = function (
const separator = getSeparator(style);

if (Array.isArray(value)) {
let joinedValue;
if (explode) {
joinedValue = value.join(separator + paramId);
} else {
joinedValue = value.join(',');
}

objects.push({
name,
value: prefix + paramId + joinedValue,
value:
prefix + paramId + value.join(explode ? separator + paramId : ','),
});

} else if (value && typeof value === 'object') {
if (explode) {
objects.push({
Expand Down Expand Up @@ -695,13 +683,9 @@ const getHeadersArray = function (openApi, path, method) {
if (typeof pathObj.security !== 'undefined') {
for (var l in pathObj.security) {
const secScheme = Object.keys(pathObj.security[l])[0];
let secDefinition;
if (openApi.securityDefinitions) {
secDefinition = openApi.securityDefinitions[secScheme];
} else {
secDefinition = openApi.components.securitySchemes[secScheme];
}

const secDefinition = openApi.securityDefinitions
? openApi.securityDefinitions[secScheme]
: openApi.components.securitySchemes[secScheme];
const authType = secDefinition.type.toLowerCase();
let authScheme = null;

Expand Down
Loading

0 comments on commit 54bd697

Please sign in to comment.