Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Explore API (generated OpenAPI spec is not valid) #1531

Closed
Vandivier opened this issue Jul 15, 2018 · 8 comments
Closed

Unable to Explore API (generated OpenAPI spec is not valid) #1531

Vandivier opened this issue Jul 15, 2018 · 8 comments
Assignees

Comments

@Vandivier
Copy link

Description / Steps to reproduce / Feature proposal

  1. lb4 example, then pick the Todo app.
  2. install it and get it running.
  3. visit http://localhost:3000/openapi.yaml
  4. paste the yaml within http://editor.swagger.io

Current Behavior

get errors:
image

Expected Behavior

don't get errors :)

@virkt25
Copy link
Contributor

virkt25 commented Jul 16, 2018

Able to reproduce. Looks like we aren't generating responses property and a few other issues possibly from JSON to YAML conversion. Great catch!

@dhmlau
Copy link
Member

dhmlau commented Aug 21, 2018

There are 2 kinds of errors when opening our generated openapi.json in editor.swagger.io:

  1. responses object is empty

    responses: {
         "200": {
           description: "some description"
         }
       }
    
  2. If in field in the parameter object is path, the following needs to exist:

required: true
i.e. 
 parameters:
     - name: id
       in: path
       schema:
         type: string
       required: true 
 ```

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#parameter-object

 

@bajtos
Copy link
Member

bajtos commented Aug 23, 2018

If in field in the parameter object is path, the following needs to exist:
required: true

I am proposing to modify our @param.path.* decorators to always set required: true. See packages/openapi-v3/src/decorators/parameter.decorator.ts.

@bajtos
Copy link
Member

bajtos commented Aug 23, 2018

I am proposing to modify our @param.path.* decorators to always set required: true. See packages/openapi-v3/src/decorators/parameter.decorator.ts.

Never mind :) A different solution has been already landed via #1633 👍

@bajtos bajtos changed the title Unable to Explore API Unable to Explore API (generated OpenAPI spec is not valid) Aug 28, 2018
@virkt25
Copy link
Contributor

virkt25 commented Aug 28, 2018

Acceptance Criteria

  • Introduce a default responses object on the generated OpenAPI Spec (responses: {200: {description: ''}}
  • Introduce a @responses decorator which takes in an OpenAPI responses object for a given controller method. This will take the exact spec. Should be able to resolve {schema: MODEL} to a model in the spec.
  • Update CLI to automatically decorate CRUD APIs with @responses() decorator

The following will be moved to a new TASK.

  • Introduce a @response decorator (must override base class to allow for multiple to be set on a controller method). This is a sugar method with a simplified UX.
    Example UX:
@response('returns a user') // auto-detect User Model
@response('confirmation of deleted instance', {type: object, schema: {status: boolean, count: number}})
@response(404, 'user not found', HttpErrors.NotFoundError)

@bajtos
Copy link
Member

bajtos commented Aug 30, 2018

I am afraid I disagree with the acceptance criteria outlined in the comment above, please see #1655 (comment)

@bajtos
Copy link
Member

bajtos commented Aug 30, 2018

The following will be moved to a new TASK: Introduce a @response decorator (must override base class to allow for multiple to be set on a controller method). This is a sugar method with a simplified UX.

@virkt25 could you please create that follow-up task and/or post a link the GH issue if it already exists?

@virkt25
Copy link
Contributor

virkt25 commented Sep 6, 2018

Follow up issue: #1672

@virkt25 virkt25 closed this as completed Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants