Giter Club home page Giter Club logo

Comments (5)

calcinai avatar calcinai commented on September 18, 2024 1

Hey, I just had a look at this and seems to be a simple fix. It's just an issue with numeric keys, but because PHP's loose types, it's not handled by default.

I'd say that by testing if the key is all numeric would be enough. Feel free to make a PR, otherwise I'll have a look at it when I get a chance.

from strut.

zeroimpl avatar zeroimpl commented on September 18, 2024

Thanks. I had worked around that issue (I think), but it seemed like there were a few other issues as well.

For example, I had been trying to figure out how to set the content of a Response object - in OAS 3.0 it seems for each status code you need to create a map from content type (eg 'application/json') to the actual object. I couldn't figure out how to get the MediaTypes class working for that, which is needed by the setContent method of Response. So I decided to try just initializing an instance from an existing OAS 3.0 spec and dump the PHP object for that, but this failed as well:

$schema = json_decode(file_get_contents('https://raw.githubusercontent.com/googleapis/gnostic/master/examples/v3.0/json/petstore.json'));
$swagger = \Calcinai\Strut3\Swagger::create($schema);
var_export( $swagger );

The above fails with:

PHP Fatal error:  Uncaught exception 'InvalidArgumentException' in Calcinai\Strut3\BaseSchema.php:201
Stack trace:
#0 BaseSchema.php(172): Calcinai\Strut3\BaseSchema::tryToCast(Array, Array)
#1 BaseSchema.php(29): Calcinai\Strut3\BaseSchema->parseData(Array)
#2 BaseSchema.php(219): Calcinai\Strut3\BaseSchema->__construct(Array)
#3 swagger-gen3test.php(53): Calcinai\Strut3\BaseSchema::create(Array)

So at the moment I'll probably stick with doing 2.0 then since it works well enough and I don't have enough time to spend on experimenting with 3.0 right now. Anyways thanks for taking a look at this.

from strut.

calcinai avatar calcinai commented on September 18, 2024

@zeroimpl did you get a chance to test this? Sorry it took me so long to get working!

from strut.

zeroimpl avatar zeroimpl commented on September 18, 2024

@calcinai Taking a look now. Looks like will be quite a few things to tweak to get my code working with the new version.
I did run into one issue so far though - calling setExample('blah') on Schema fails with:

exception 'InvalidArgumentException' with message '[Calcinai\Strut\Definitions\Schema] does not accept property [example]'

I think in Schema.php you need to replace

'example' => ['mixed']

with

'example' => []

There are a few other places with reference to 'mixed' as well.

from strut.

calcinai avatar calcinai commented on September 18, 2024

Oh man, it's so close! I'll take a look at it soon

from strut.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.