Giter VIP home page Giter VIP logo

Comments (11)

mtrajano avatar mtrajano commented on May 29, 2024 1

Hey I'm sorry I just got a chance to look at this, a fix has been pushed to master. If you're curious this was the fix: 9c9e10a it broke during the last pr when someone tried fixing something unrelated. Give it a try and let me know if it works, I'm going to push some other minor things and then release 0.6.3 with this fix

from laravel-swagger.

mtrajano avatar mtrajano commented on May 29, 2024

This is a great suggestion, I’ll look into how difficult this would be. I’m guessing there’s something out there that does this already but it would definitely make sense being part of the lib

from laravel-swagger.

syntaxlexx avatar syntaxlexx commented on May 29, 2024

@mtrajano yes there's this package darkaonline/l5-swagger that has the Swagger UI, but it feels very redundant having to require two swagger-api generators in a project; one for generating, and one for viewing the generated docs. It would really help and come in handy if this awesome package would include it.

from laravel-swagger.

mtrajano avatar mtrajano commented on May 29, 2024

@lexxyungcarter thanks for the pointer I was unsure about this as I thought you needed js to build the files but it looks like Swagger provides bundled js files as a composer package that can be added in a package view file. I will look into this as soon as I’m done working on the securityDefinitions issue #17. Feel free to take a stab at it if you can get to it before me, thank you!

from laravel-swagger.

mtrajano avatar mtrajano commented on May 29, 2024

I think ideally this should be a separate command, say laravel-swagger:view or something like that as not everyone might want these files to be added. Would also add a path in the config so the user can choose where the pages should live, maybe default to /docs as that seems to be the convention.

from laravel-swagger.

syntaxlexx avatar syntaxlexx commented on May 29, 2024

Yes. That seems right to me. Or even better, publish the view assrts to reources/views/vendor just as other packages such as laravel horizon, mailables, e.t.c.

from laravel-swagger.

syntaxlexx avatar syntaxlexx commented on May 29, 2024

Can't wait for the next release of Laravel Swagger!

@mtrajano Is it just me or is there an an issue with 'reading' the type-hinted Requests in the controller? Of late, I can't seem to get mine showing the parameters in the docs.

from laravel-swagger.

mtrajano avatar mtrajano commented on May 29, 2024

@lexxyungcarter me neither, a lot of exciting stuff coming! And that’s weird if you typehint a FormRequest instance in your controller action it should automatically generate the request params for you, it does that based on the rules array you define. Are you getting some sort of error when running or is it just not picking it up? If you share a specific file it might help when looking into it, additionally you can also take a look at the test files for some examples, thanks!

from laravel-swagger.

syntaxlexx avatar syntaxlexx commented on May 29, 2024

@mtrajano No errors pop up, it's just not picking up. Here's an example:

    /**
     * create a new contact message
     *
     * @param ContactMessageRequest $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function store(ContactMessageRequest $request)
    {
        $response = $this->repo->create(true);

        if($response)
            return response()->json([
                'message' => 'Thank you for your message. We will keep in touch.',
                'alert' => 'success',
            ], 200);

        return response()->json([
            'message' => 'There was an error sending your message. Please try again or refresh the page.',
            'alert' => 'error',
        ], 422);

    }

Request

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ContactMessageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'concern_id' => 'nullable|numeric',
            'name' =>  'required|string|max:255',
            'email' =>  'required|email|max:255',
            'phone' =>  'required|max:20',
            'body' => 'required|max:500',
            'country_id' => 'nullable|numeric|exists:countries,id',
        ];
    }
}

I have a command that calls the laravel swagger command, which is:

        $this->call('laravel-swagger:generate', [
            '--filter' => '/api',
            '--output' => 'storage/api-docs/api-docs.json',
        ]);

However, the generated docs becomes:

         "\/api\/contact-messages": {
            "get": {
                "summary": "return all",
                "description": "",
                "deprecated": false,
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "post": {
                "summary": "create a new contact message",
                "description": "",
                "deprecated": false,
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },

As for the other routes, the route parameters get passed as expected, but not the type-hinted Requests. Any clue on what could be wrong? Thank you.

from laravel-swagger.

mtrajano avatar mtrajano commented on May 29, 2024

Hey, appologies for the late response. It looks like there was a pull request fixing something similar to what you're saying. Would mind upgrading to 0.6.2 and giving it a try again? I can take a look in a few as well and verify, thanks

from laravel-swagger.

syntaxlexx avatar syntaxlexx commented on May 29, 2024

Wallah! It works now! dev-master branch

from laravel-swagger.

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.