Giter VIP home page Giter VIP logo

Comments (4)

byjg avatar byjg commented on June 28, 2024

Hi There!

At this moment the code does not offer support for reference parameters.

Probably I can implemented something in a few weeks. If you have some piece of code would be helpful.

from php-swagger-test.

JurisU avatar JurisU commented on June 28, 2024

JSON schema:

openapi: 3.0.0
info:
paths:
    '/tests/{test_id}':
        get:
            parameters:
                -
                    $ref: '#/components/parameters/count'
                -
                    $ref: '#/components/parameters/offset'
            responses:
                '200':
                    description: 'Empty response'
                    content:
                        application/json:
                            schema:
                                description: 'Empty response'
        parameters:
            -
                $ref: '#/components/parameters/test_id'
components:
    parameters:
        count:
            name: count
            in: query
            required: false
            schema:
                type: integer
                default: 10
                maximum: 500
                readOnly: true
        offset:
            name: offset
            in: query
            required: false
            schema:
                type: integer
                default: 0
                readOnly: true
        test_id:
            name: test_id
            in: path
            required: true
            schema:
                type: string

This schema is not valid for Swagger v2.0, i can't test on master branch

PHP code:

<?php

$openApiSchema = file_get_contents('openapi.json');

$this->swaggerSchema = new \ByJG\Swagger\SwaggerSchema($openApiSchema, true);

$bodyResponseDef = $swaggerSchema->getResponseParameters(
    $requestURI,
    $requestMethod,
    $responseStatusCode
);
$this->assertTrue($bodyResponseDef->match(json_decode($responseContent, true)));

Errors:

  1. [PHPUnit\Framework\Exception] Undefined index: parameters.
    trace:
/webroot/vendor/codeception/codeception/src/Codeception/Subscriber/ErrorHandler.php:83
/webroot/vendor/byjg/swagger-test/src/SwaggerSchema.php:103
/webroot/vendor/byjg/swagger-test/src/SwaggerSchema.php:209
/webroot/tests/_support/Helper/Api.php:87
/webroot/vendor/codeception/codeception/src/Codeception/Step.php:265
/webroot/vendor/codeception/codeception/src/Codeception/Scenario.php:72
...
/webroot/vendor/codeception/codeception/codecept:43
  1. When i resolve references, i have other exception: [PHPUnit\Framework\Exception] Undefined index: count. count is parameter from query
/webroot/vendor/codeception/codeception/src/Codeception/Subscriber/ErrorHandler.php:83
/webroot/vendor/byjg/swagger-test/src/SwaggerSchema.php:123
/webroot/vendor/byjg/swagger-test/src/SwaggerSchema.php:103
/webroot/vendor/byjg/swagger-test/src/SwaggerSchema.php:209
/webroot/tests/_support/Helper/Api.php:87
/webroot/vendor/codeception/codeception/src/Codeception/Step.php:265
/webroot/vendor/codeception/codeception/src/Codeception/Scenario.php:72
...
/webroot/vendor/codeception/codeception/codecept:43

from php-swagger-test.

byjg avatar byjg commented on June 28, 2024

Hello @JurisU, this definition will not work on master branch because the OpenApi Spec 3.0 still in development on branches oas30 and issue-23 (this issue)

from php-swagger-test.

byjg avatar byjg commented on June 28, 2024

I commit a version that resolves the issue.

We have the same behavior from the Swagger 2.0 validating only the "path". I would like to know if is interesting to validate parameters in other parts --> "query", "header", "path" or "cookie". (at least "query" should be interesting).

from php-swagger-test.

Related Issues (20)

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.