@click.command('spec',short_help='Show the OpenAPI spec.')@click.option('--format','-f',type=click.Choice(['json','yaml','yml']),help='The format of the spec, defaults to SPEC_FORMAT config.',)@click.option('--output','-o',type=click.Path(),help='The file path to the spec file, defaults to LOCAL_SPEC_PATH config.',)@click.option('--indent','-i',type=int,help='The indentation for JSON spec, defaults to LOCAL_SPEC_JSON_INDENT config.',)@click.option('--quiet','-q',type=bool,is_flag=True,help='A flag to suppress printing output to stdout.')@with_appcontextdefspec_command(format,output,indent,quiet):"""Output the OpenAPI spec to stdout or a file. Check out the docs for the detailed usage: https://apiflask.com/openapi/#the-flask-spec-command """spec_format=formatorcurrent_app.config['SPEC_FORMAT']spec=current_app._get_spec(spec_format)output_path=outputorcurrent_app.config['LOCAL_SPEC_PATH']ifindentisNone:indent=current_app.config['LOCAL_SPEC_JSON_INDENT']json_indent=Noneifindent==0elseindentifspec_format=='json':spec=json.dumps(spec,indent=json_indent)# output to stdoutifnotquiet:click.echo(spec)# output to local fileifoutput_path:withopen(output_path,'w')asf:click.echo(spec,file=f)