[QUESTION] Why do error occur with `--ignore-file-override` option ?
Created by: yuji38kwmt
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
When I execute generate
subcommand with --ignore-file-override
option, the following error occurred.
Why did error occurr ?
Removing --ignore-file-override
option, error did not occur.
$ java -Dapis -DapiTests=false -DapiDocs=false -jar openapi-generator-cli-4.0.0.jar generate -g python -i petstore-simple.yaml -o out --ignore-file-override=openapi-generator-ignore
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: python (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'python' is considered stable.
[main] INFO o.o.c.languages.PythonClientCodegen - Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"' (Linux/Mac)
[main] INFO o.o.c.languages.PythonClientCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI). Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'animals'
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:666)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:922)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:396)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Caused by: java.lang.NullPointerException
at org.openapitools.codegen.ignore.CodegenIgnoreProcessor.allowsFile(CodegenIgnoreProcessor.java:145)
at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:955)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:617)
... 3 more
openapi-generator version
openapi-generator-cli-4.0.0.jar
- java version "1.8.0_162"
OpenAPI declaration file content or url
petstore-simple.yaml
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
- animals
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
openapi-generator-ignore
file
openapi_client/api/pets_api.py
Command line used for generation
$ java -Dapis -DapiTests=false -DapiDocs=false \
-jar openapi-generator-cli-4.0.0.jar generate \
-g python -i petstore-simple.yaml \
-o out --ignore-file-override=openapi-generator-ignore
Steps to reproduce
Related issues/PRs
I referred to Ignore file format