Comments (3)
Oops, yep that's a crash:
$ go install && stripe-mock -port 12112
stripe-mock master
Routing to 115 path(s) and 197 endpoint(s) with 108 validator(s)
Listening on port 12112
Request: GET /v1/charges/ch_123
2018/02/20 12:05:09 http: panic serving [::1]:61521: Responding to /v1/charges/ch_123:
Dereferencing '#/components/schemas/charge':
Using fixture 'charge':
In property 'outcome' of object:
Choosing only branch of anyOf:
Dereferencing '#/components/schemas/charge_outcome':
In property 'rule' of object:
Expanding optional expandable field:
Dereferencing '#/components/schemas/rule':
Cannot find or generate example for: {
"properties": {
"action": {
"type": "string"
},
"id": {
"type": "string"
},
"predicate": {
"type": "string"
}
},
"required": [
"action",
"id",
"predicate"
],
"type": "object",
"x-expandableFields": []
}
goroutine 8 [running]:
net/http.(*conn).serve.func1(0xc4202bafa0)
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:1697 +0xd0
panic(0x134f140, 0xc42012a5d0)
/usr/local/Cellar/go/1.9.1/libexec/src/runtime/panic.go:491 +0x283
main.(*DataGenerator).generateInternal(0xc4209e5b10, 0xc420180960, 0xc4202ec604, 0x12, 0xc42055b7a0, 0x0, 0xc420096f20, 0x14a, 0x0, 0xc420624280, ...)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:121 +0x192c
main.(*DataGenerator).generateInternal(0xc4209e5b10, 0xc4201805a0, 0xc4202ec604, 0x12, 0xc42055b7a0, 0x0, 0xc42000ad00, 0xfa, 0x134f140, 0xc42085e990, ...)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:72 +0xfba
main.(*DataGenerator).generateInternal(0xc4209e5b10, 0xc420167360, 0xc4202ec604, 0x12, 0xc42055b780, 0xc42055bdf0, 0xc4200e82a0, 0xdc, 0x0, 0xc42085e940, ...)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:187 +0x59c
main.(*DataGenerator).generateInternal(0xc4209e5b10, 0xc420167220, 0xc4202ec604, 0x12, 0xc42055b780, 0xc42055bdf0, 0xc42043dd40, 0x88, 0x134f140, 0xc42085e960, ...)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:93 +0xe5a
main.(*DataGenerator).generateInternal(0xc4209e5b10, 0xc4202981e0, 0xc4202ec604, 0x12, 0xc42055b760, 0xc42055b7e0, 0xc420022af0, 0x67, 0x1, 0xc42021e2a0, ...)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:187 +0x59c
main.(*DataGenerator).Generate(0xc4203a9b10, 0xc4202981e0, 0xc4202ec604, 0x12, 0xc42055b760, 0x1, 0x0, 0x0, 0x160ce01)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/generator.go:23 +0x120
main.(*StubServer).HandleRequest(0xc42064ef40, 0x159d240, 0xc4206c6000, 0xc42079e300)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/server.go:203 +0x652
main.(*StubServer).HandleRequest-fm(0x159d240, 0xc4206c6000, 0xc42079e300)
/Users/brandur/Documents/go/src/github.com/stripe/stripe-mock/main.go:75 +0x48
net/http.HandlerFunc.ServeHTTP(0xc42055b640, 0x159d240, 0xc4206c6000, 0xc42079e300)
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:1918 +0x44
net/http.(*ServeMux).ServeHTTP(0x15ec5e0, 0x159d240, 0xc4206c6000, 0xc42079e300)
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:2254 +0x130
net/http.serverHandler.ServeHTTP(0xc4202efad0, 0x159d240, 0xc4206c6000, 0xc42079e300)
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc4202bafa0, 0x159d8c0, 0xc420662c80)
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.9.1/libexec/src/net/http/server.go:2720 +0x288
Shouldn't be too hard to shore this up. I'll take a look.
from stripe-mock.
Just as a quick update: I looked into this one, and the reason this fails where other places don't is that right now we'll attempt to use fixture that's usually pre-specified in fixtures3
most of the time and generate a few special types of objects (like lists), but right now we fail with the message above if we can't do one of those.
Outcome and rule are a special case because they're API resources that we don't have a top-level resource for, and so the generator balks when it gets to them.
Solutions might include:
- Try to include even these types of nested resources in
fixtures3
. - Allow
stripe-mock
to generate dummy data in this sort of case where just introspect each field and try to generate the minimum viable object (i.e., empty strings, zeroed integers and decimals, etc.).
The better approach is probably the latter so — it'd shore things up for now, and still allow us to generate higher fidelity subresource fixtures for fixtures3
that will supersede the dummy data when it's available.
from stripe-mock.
I ended up going with option (2) above.
Confirmed that #48 fixes this problem:
$ curl -vvvv -g "http://localhost:12112/v1/charges/ch_123?expand[]=outcome.rule" -u sk_test_123:
* Couldn't find host localhost in the .netrc file; using defaults
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 12112 (#0)
* Server auth using Basic with user 'sk_test_123'
> GET /v1/charges/ch_123?expand[]=outcome.rule HTTP/1.1
> Host: localhost:12112
> Authorization: Basic c2tfdGVzdF8xMjM6
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Request-Id: req_123
< Stripe-Mock-Version: master
< Date: Sat, 14 Apr 2018 00:12:13 GMT
< Content-Length: 966
< Content-Type: text/plain; charset=utf-8
<
{
"amount": 100,
"amount_refunded": 0,
"balance_transaction": "txn_1CDJmuCLWM6HLS3K1JZYeh6X",
"captured": false,
"created": 1234567890,
"currency": "usd",
"description": "My First Test Charge (created for API docs)",
"fraud_details": {},
"id": "ch_123",
"livemode": false,
"metadata": {},
"object": "charge",
"outcome": {
"rule": {
"action": "",
"id": "",
"predicate": ""
},
"type": ""
},
"paid": true,
"refunded": false,
"refunds": {
"data": [
{
"amount": 100,
"charge": "ch_123",
"created": 1234567890,
"currency": "usd",
"id": "re_1CDJmuCLWM6HLS3KE6PhPJEl",
"metadata": {},
"object": "refund",
"status": "succeeded"
}
],
"has_more": false,
"object": "list",
"url": "/v1/charges/ch_123/refunds"
},
"source": {
"id": "acct_1CDJjyCLWM6HLS3K",
"object": "account"
},
"status": "succeeded"
}
* Connection #0 to host localhost left intact
from stripe-mock.
Related Issues (20)
- Support subscription discount removal HOT 1
- Release 0.120.0 appears to be broken HOT 3
- DockerImage : lastest is too old HOT 3
- Readme for docker is outdated HOT 1
- A newly created checkout session status is coming as "expired" HOT 2
- Return mock of complex objects HOT 1
- Response content-type should be application/json rather than text/plain HOT 2
- The response from `/v1/invoices/:id/finalize` is wrong HOT 1
- Add an ability to register user-defined responses with idempotency_key HOT 1
- checkout session has no URL HOT 7
- Subscription create should send back the same amount of subscription item as the number of items HOT 1
- Create checkout sessions needs an optional parameter HOT 2
- Can we specify what data is on a checkout session retrieval? HOT 2
- Payment link creation not currently mocked ? HOT 2
- Cardholder replacment because of `cardholder_reassigned` reason HOT 2
- Is this up to date with Stripe API ? HOT 4
- Support sending webhooks HOT 1
- Checkout session missing the `created` key HOT 3
- Create Subscription Schedule returns sub ID incorrectly HOT 1
- Error retrieving bank accounts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stripe-mock.