Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/httpsnippet-client-api/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__tests__/__fixtures__/
__tests__/__fixtures__/output/*
coverage/
node_modules/
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
HTTP Snippet
https://www.npmjs.com/package/httpsnippet
--------------------

The MIT License (MIT)

Copyright (c) 2015 Mashape (https://www.mashape.com)
Expand Down
5 changes: 4 additions & 1 deletion packages/httpsnippet-client-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ HTTPSnippet.addTargetClient('node', client);
const snippet = new HTTPSnippet(harObject);
console.log(
snippet.convert('node', 'api', {
apiDefinitionPath: 'https://example.com/openapi.json'
apiDefinitionUri: 'https://example.com/openapi.json'
apiDefinition: {
/* an OpenAPI definition object */
}
})
);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const sdk = require('api')('https://example.com/openapi.json');

sdk.post('/har')
.then(res => res.json())
.then(res => {
console.log(res);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const sdk = require('api')('https://example.com/openapi.json');

sdk.get('/har', {accept: 'application/json', 'x-foo': 'Bar'})
sdk.get('/har', {'x-foo': 'Bar'})
.then(res => res.json())
.then(res => {
console.log(res);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const sdk = require('api')('https://example.com/openapi.json');

sdk.auth('123').findPetsByStatus({status: 'available', accept: 'application/xml'})
.then(res => res.json())
.then(res => {
console.log(res);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const sdk = require('api')('https://example.com/openapi.json');

sdk.auth('a5a220e').findPetsByStatus({status: 'available', accept: 'application/xml'})
.then(res => res.json())
.then(res => {
console.log(res);
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "application-form-encoded"
},
"servers": [
{
"url": "http://mockbin.com"
}
],
"paths": {
"/har": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"hello": {
"type": "string"
}
}
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"log": {
"entries": [
{
"request": {
"method": "POST",
"url": "http://mockbin.com/har",
"headers": [
{
"name": "content-type",
"value": "application/x-www-form-urlencoded"
}
],
"postData": {
"mimeType": "application/x-www-form-urlencoded",
"params": [
{
"name": "foo",
"value": "bar"
},
{
"name": "hello",
"value": "world"
}
]
}
}
}
]
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0",
"title": "application-json"
},
"servers": [
{
"url": "http://mockbin.com"
}
],
"paths": {
"/har": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"number": {
"type": "number"
},
"string": {
"type": "string"
},
"arr": {
"type": "array",
"items": {
"type": "number"
}
},
"nested": {
"type": "object",
"properties": {
"a": {
"type": "string"
}
}
},
"arr_mix": {
"type": "array",
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "string"
},
{
"properties": {
"arr_mix_nested": {
"type": "object",
"properties": {}
}
},
"type": "object"
}
]
}
},
"boolean": {
"type": "boolean"
}
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"log": {
"entries": [
{
"request": {
"method": "POST",
"url": "http://mockbin.com/har",
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"postData": {
"mimeType": "application/json",
"text": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}"
}
}
}
]
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0",
"title": "cookies"
},
"servers": [
{
"url": "http://mockbin.com"
}
],
"paths": {
"/har": {
"post": {
"parameters": [
{
"in": "cookie",
"name": "foo",
"schema": {
"type": "string"
}
},
{
"in": "cookie",
"name": "bar",
"schema": {
"type": "string"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"log": {
"entries": [
{
"request": {
"method": "POST",
"url": "http://mockbin.com/har",
"cookies": [
{
"name": "foo",
"value": "bar"
},
{
"name": "bar",
"value": "baz"
}
]
}
}
]
}
}

This file was deleted.

This file was deleted.

Loading