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

CobiGen should warn that it is not a valid OpenAPI #873

Closed
jdiazgon opened this issue May 7, 2019 · 2 comments
Closed

CobiGen should warn that it is not a valid OpenAPI #873

jdiazgon opened this issue May 7, 2019 · 2 comments
Assignees

Comments

@jdiazgon
Copy link
Member

jdiazgon commented May 7, 2019

Description

CobiGen should warn the user that the OpenAPI specification file that he is trying to use for CobiGen in order to generate code, is not a valid OpenAPI 3.0.0 specification.

Therefore, if it is not a valid file, it should popup a message describing that. It could be interesting to also specify why it is not a valid OpenAPI 3.0.0 definition.

CobiGen should always work with valid OpenAPI 3.0.0 specification files. You can test if your OpenAPI specification file is valid by using this link.

In our current implementation, we are using a parser called RepreZen. Most probably there is already a method to validate an OpenAPI file like:

isValidOpenApi(file)

Therefore we should investigate this and try to implement this logic.


For instance, this is an example of an invalid yaml file that breaks CobiGen:

If I try to generate from an OpenAPI definition of a component, and that component defines a property that references a missing component, CobiGen gets broken.

This is the component that breaks CobiGen:

components:
  schemas:
        Author:
          x-component: authormanagement
          description: Entity definiton of Author
          properties:
            errorList:
              type: array
              items:
                $ref: "#/components/schemas/ErrorResponse_errorList"

As the component ErrorResponse_errorList is missing, it throws this error:

image

The error message should be:

This is not a valid OpenAPI 3.0.0 specification because of "reason". Please change your file in order to follow OpenAPI 3.0.0 standards.

If I add the component, it works fine:

        ErrorResponse_errorList:
          x-component: measuringpoint  
          type: object
          properties:
            errorCode:
              type: string
            errorMessage:
              type: string

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. Create a .yml file on the root of your project and add the following content:
openapi: 3.0.0
servers:
  - url: 'https://localhost:8081/server/services/rest'
    description: Just some data
info:
  title: Devon Example
  description: Example of a API definition
  version: 1.0.0
  x-rootpackage: com.devonfw.poc.jwtsample
paths:
  /authormanagement/v1/author/:
    post:
      responses:
        '200':
          description: Any
components:
    schemas:
        Author:
          x-component: authormanagement
          type: object
          description: Entity definiton of Author
          properties:
            errorList:
              type: array
              items:
                $ref: "#/components/schemas/ErrorResponse_errorList"
       
  1. Click on CobiGen -> Generate .
  2. It will throw an error.
@mandybuchhold
Copy link
Contributor

@github-actions
Copy link

Stale issue message

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

3 participants